<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../lib/vue.js"></script>
</head>
<body>

    <div id="app">
        <com1></com1>
    </div>

    <template id="com1">
        <div>
            组件1---{{msg}}
            <button @click="handle">加2</button>
        </div>
    </template>

    <script>
        function fun(val){
            this.msg+=val;
        }
        var com1={
            template: "#com1",
            data() {
                return {
                    msg: 0,
                    fun1: ''
                }
            },
            methods: {
                handle() {
                    this.fun1(1);
                }
            },
            created() {
                this.fun1=fun.bind(this);
            }
        };
        Vue.component('com1', com1);
        var vm = new Vue({
            el: "#app"
        });


    </script>
</body>
</html>